﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Public
{
    public partial class wfDjackVehicle2 : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindControls();
            }
        }
        private void BindControls()
        {
            if (!IsPostBack)
            {
            }
        }

        private void getUserInfo(string djackId)
        {
            if (string.IsNullOrEmpty(djackId))
            {
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizVehicleInfo vehicleInfo = new AppLogic.DataAlc.CBizVehicleInfo())
            {
                DataSet ds = vehicleInfo.SelectByIds(djackId, "");
                if (ds == null)
                {
                    return;
                }
                string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                this.ExecJScript(@"setDjackInfo(" + retJson + ");");
            }
        }

        private void djackVehicle(string djackId)
        {
            if (string.IsNullOrEmpty(djackId))
            {
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizDjackSpecieInfo specieInfo = new AppLogic.DataAlc.CBizDjackSpecieInfo())
            {
                DataSet ds = specieInfo.SelectVehicleById(djackId);
                if (ds == null)
                {
                    return;
                }
                DataColumn dr = new DataColumn("VEHICLE_BRAND_NAME");
                ds.Tables[0].Columns.Add(dr);
                DataColumn dr1 = new DataColumn("VEHICLE_SERVICE_TYPE_NAME");
                ds.Tables[0].Columns.Add(dr1);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    ds.Tables[0].Rows[i]["VEHICLE_BRAND_NAME"] = Enum.GetName(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleBrandEnum), Convert.ToInt32(ds.Tables[0].Rows[i]["VEHICLE_BRAND"].ToString()));

                    ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE_NAME"] = Enum.GetName(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.ServiceTypeEnum), Convert.ToInt32(ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE"].ToString()));
                }
                string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0],"","",1,1000,"");
                this.ExecJScript(@"
                            var _html = $('#svc_list_temp_vehicle').html();

                            laytpl(_html).render(" + retJson + @", function (render) {
                                $('#carList').html(render);
                            });
            $('#vertical').height($('#carList').height());
            $('#verticalBottom').height($('#carList').height() - 28);");
            }
        }

        public override void DoAction()
        {
            if (this.strAction == "djackVehicle")
            {
                string djackId = this.GetParamHtValue("djackId");
                getUserInfo(djackId);
                djackVehicle(djackId);
            }

        }
    }
}